<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script setup>
import useSettingsStore from '@/store/modules/settings'
import { handleThemeStyle } from '@/utils/theme'
import {ElMessage} from "element-plus";

onMounted(() => {
  nextTick(() => {
    // 初始化主题样式
    handleThemeStyle(useSettingsStore().theme)
  })

  if (import.meta.env.VITE_APP_ENV==='production') {
    (function noDebugger() {
      function testDebugger() {
        var d = new Date();
        debugger;
        if (new Date() - d > 10) {
          // 页面加载完成后执行
          document.addEventListener('DOMContentLoaded', function() {
            // 设置页面样式
            document.body.style.margin = '0';
            document.body.style.padding = '0';
            document.body.style.minHeight = '100vh';
            document.body.style.display = 'flex';
            document.body.style.justifyContent = 'center';
            document.body.style.alignItems = 'center';
            document.body.style.fontFamily = '"Microsoft YaHei", sans-serif';
            document.body.style.backgroundColor = '#f8f9fa';

            // 创建提示元素
            const warningDiv = document.createElement('div');
            warningDiv.innerHTML = '<div>管理员已禁用调试模式!!!年轻人，不要太好奇</div>';

            // 设置提示元素样式
            warningDiv.style.textAlign = 'center';
            warningDiv.style.padding = '40px';
            warningDiv.style.maxWidth = '600px';
            warningDiv.style.width = '90%';
            warningDiv.style.borderRadius = '12px';
            warningDiv.style.boxShadow = '0 10px 30px rgba(0, 0, 0, 0.1)';
            warningDiv.style.backgroundColor = 'white';

            // 设置文本样式
            const textElement = warningDiv.querySelector('div');
            textElement.style.color = '#e74c3c';
            textElement.style.fontSize = '24px';
            textElement.style.fontWeight = 'cursive';
            textElement.style.lineHeight = '1.6';
            textElement.style.animation = 'pulse 2s infinite';

            // 添加动画效果
            const style = document.createElement('style');
            style.textContent = `
        @keyframes pulse {
          0% { transform: scale(1); }
          50% { transform: scale(1.05); }
          100% { transform: scale(1); }
        }
      `;
            document.head.appendChild(style);

            // 清空并添加新内容
            document.body.innerHTML = '';
            document.body.appendChild(warningDiv);
          });

          return true;
        }
        return false;
      }

      function start() {
        while (testDebugger()) {
          testDebugger();
        }
      }

      if (!testDebugger()) {
        window.onblur = function () {
          setTimeout(function () {
            start();
          }, 500);
        };
      } else {
        start();
      }
    })();
  }

})
</script>
<style scoped>
#app {
  /* font-family: Avenir, Helvetica, Arial, sans-serif; */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* width: 100vw; */
  height: 100vh;
  overflow: hidden;
  box-sizing: border-box;

}
</style>
